package com.hdu.hdu.interceptor;

import com.hdu.hdu.context.StudentInfoCheckContext;

public class NameCheckInterceptor implements Interceptor<StudentInfoCheckContext> {
    @Override
    public void handle(StudentInfoCheckContext context) {
        String username = context.getStudent().getUsername();
        if (username == null || username.length() < 2) {
            context.getErrorMsg().put("NameCheckInterceptor", "用户名不能为空");
        }
        else if (username.length() > 10) {
            context.getErrorMsg().put("NameCheckInterceptor", "用户名不能超过10个字符");
        }
    }
}
